<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <style>
    body {
      text-align: center;
    }
    table {
      margin: auto;
    }
  </style>
</head>
<body>
<h1 style="text-align: center">文件服务</h1>
<br>

<br>
<div>
  <form method="POST" enctype="multipart/form-data" action="/mongodb/upload" target="id_iframe">
    <table>
      <tr>
        <td>上传文件:</td>
        <td><input type="file" name="file" multiple="multiple"/></td>
        <td><input type="hidden" name="alias" th:value="${alias}"/></td>
        <td><input type="submit" value="上传" onclick="return true;"/></td>
      </tr>
    </table>
  </form>
</div>
<br><br>
<iframe id="id_iframe" name="id_iframe" style="display:none;"></iframe>

<div style="margin-left: 5%">
  <h3 style="text-align: center">文件列表</h3>
  <table border="1">
    <thead>
    <tr style="background-color: beige">
      <td>文件名</td>
      <td>文件ID</td>
      <td>contentType</td>
      <td>文件大小</td>
      <td>上传时间</td>
      <td>md5</td>
      <td>操作</td>
    </tr>
    </thead>
    <tbody>
    <tr th:if="${files.size()} eq 0">
      <td colspan="3">没有文件信息！！</td>
    </tr>
    <tr th:each="file : ${files}">
      <td><a th:href="'files/'+${file.id}" th:text="${file.name}"/></td>
      <td th:text="${file.id}"></td>
      <td th:text="${file.contentType}"></td>
      <td th:text="${file.size}"></td>
      <td th:text="${file.uploadDate}"></td>
      <td th:text="${file.md5}"></td>
      <td>
        <a target="_blank" th:href="@{'/mongodb/view/'+${file.id}(alias=${alias})}">预览</a>|
        <a target="_blank" th:href="@{'/mongodb/'+${file.id}(alias=${alias})}">下载</a>|
        <a th:href="@{'/mongodb/delete'+${file.id}(alias=${alias})}">删除</a>
      </td>
    </tr>
    </tbody>
  </table>
</div>

</body>
